﻿using System;

namespace PageAdmin.Utils
{
    /// <summary>
    /// 通用提示类，用户也可以自行定义，或继承使用
    /// </summary>
    [Serializable]
    public class TipsInfo
    {
        /// <summary>
        /// 0：操作失败，1，操作成功，主要用于对数据或内容的请求状态描述
        /// </summary>
        public int State { get; set; }=1;

        /// <summary>
        /// http请求的状态码，主要用于对权限的描述
        /// </summary>
        public HttpCodeEnum HttpCode { get; set; }= HttpCodeEnum.OK;

        /// <summary>
        /// 返回前端的提示信息。
        /// </summary>
        public string Msg { get; set; } = "success";

        /// <summary>
        /// 自定义描述，根据需求自定义判断
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// 返回前端的数据
        /// </summary>
        public dynamic Data{ get; set; }

        /// <summary>
        /// 往前端输出的header数据,或自定义的数据
        /// </summary>
        public dynamic Header { get; set; }
    }


    /// <summary>
    /// http请求的状态码枚举
    /// </summary>
    public enum HttpCodeEnum
    {
        /// <summary>
        /// 成功
        /// </summary>
        OK = 200,


        BadRequest=400,
        /// <summary>
        /// 未登录，或登录超时，口令牌、用户名、密码错误
        /// </summary>
        Unauthorized = 401,

        /// <summary>
        /// 页面未找到
        /// </summary>
        NotFound = 404,

        /// <summary>
        /// 没有权限，禁止访问
        /// </summary>
        Forbidden = 403,

        /// <summary>
        /// 不接受请求
        /// </summary>
        NotAcceptable = 406,

        /// <summary>
        /// 请求超时
        /// </summary>
        RequestTimeout =408,

        /// <summary>
        /// id，对应数据不存在的错误。
        /// </summary>
        NotExists=410,


        /// <summary>
        /// http500 错误
        /// </summary>
        InternalServerError = 500,

        /// <summary>
        /// 服务不可用
        /// </summary>

        ServiceUnavailable= 503
    }

}
